/**
 * 
 */
package sg.edu.nus.iss.vmcs.payment;

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author moe
 *
 */
public class NetsListener implements ActionListener {

	public static final String CARD_INSERTED = "CARD_INSERTED";
	public static final String CARD_COLLECTED = "CARD_COLLECTED";
	
	public static final String NETS_ERROR = "NETS_ERROR";
	public static final String NO_NETS_ERROR = "NO_NETS_ERROR";
	
	private NetsReader ctrl = null;
	
	public NetsListener(NetsReader controller){
		this.ctrl = controller;
	}
	
	public void actionPerformed(ActionEvent e) {
		Button btn = (Button) e.getSource();
		String cmd = btn.getActionCommand();
		if (cmd.equalsIgnoreCase(CARD_INSERTED)){
			ctrl.cardInserted();
		}else if (cmd.equalsIgnoreCase(CARD_COLLECTED)){
			ctrl.cardCollected();
		}else if (cmd.equalsIgnoreCase(NETS_ERROR)){
			ctrl.setNetsError(true);
		}else if (cmd.equalsIgnoreCase(NO_NETS_ERROR)){
			ctrl.setNetsError(false);
		}	
	}

}
